package com.itcam.imitate;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @author : Cammy.Wu
 * Description : 无中生有的机器人（构造实例）
 */

public class Story04 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<?> robotClass = Class.forName("com.itcam.imitate.Robot");
        Constructor<?> constructor = robotClass.getConstructor();
        Robot newRobot = (Robot) constructor.newInstance();
        newRobot.sayHello();
    }
}
